package god.dream.loginfo.model;

import god.dream.user.model.User;

import org.apache.commons.lang.builder.EqualsBuilder;

public class LogInfo {
	private int id;
	private String loginId;
	private String loginPw;
	private int userId;
	private int admin;
	
	public LogInfo() {
	}

	public LogInfo(int id, String loginId, String loginPw, int id2) {
		this.id = id;
		this.loginId = loginId;
		this.loginPw = loginPw;
		this.userId = id2;
	}
	public Object[] insert() {
		return new Object[] { getId(), getLoginId(), getLoginPw(), getUserId() };
	}

	public Object[] update() {
		return new Object[] { getLoginId(), getLoginPw(), getUserId(), getAdmin(), getId()};
	}
	public boolean isAdministrator() {
		if( admin == 0 ) {
			return false;
		}
		
		if( admin == 1 ) {
			return true;
		}

		return false;
	}
	public boolean isMatchPassword(String inputPassword) {
		if (getLoginPw().equals(inputPassword)) {
			return true;
		} else {
			return false;
		}
	}
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof LogInfo == false) {
			return false;
		}
		if (this == obj) {
			return true;
		}

		LogInfo logInfo = (LogInfo) obj;
		return new EqualsBuilder()
				.append(getId(), logInfo.getId())
				.append(getLoginId(), logInfo.getLoginId())
				.append(getLoginPw(), logInfo.getLoginPw())
				.append(getUserId(), logInfo.getUserId())
				.isEquals();
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getLoginId() {
		return loginId;
	}

	public void setLoginId(String loginId) {
		this.loginId = loginId;
	}

	public String getLoginPw() {
		return loginPw;
	}

	public void setLoginPw(String loginPw) {
		this.loginPw = loginPw;
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public int getAdmin() {
		return admin;
	}

	public void setAdmin(int admin) {
		this.admin = admin;
	}	
	
}
